package com.aaa.a1109.demo02;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author 荆豪峰
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) {
        MXGN target=new MX();
        ClassLoader classLoader = target.getClass().getClassLoader();
        Class<?>[] interfaces = target.getClass().getInterfaces();
        InvocationHandler invocationHandler=new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                 method.invoke(target,args);
                return null;
            }
        };
        MXGN o = (MXGN) Proxy.newProxyInstance(classLoader, interfaces, invocationHandler);
         o.sing();
    }
}
interface MXGN {
    public void sing();
    public void dance();
}
class MX implements MXGN {

    @Override
    public void sing() {
        System.out.println("明星会唱");
    }

    @Override
    public void dance() {
        System.out.println("明星会跳");
    }
}